#ifndef UTILS_HEADER
#define UTILS_HEADER

#include<string>
#include<fstream>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<limits>
#include<random>
#include <iomanip>

#include "def.hpp"

using namespace std;

using namespace Puza;

template <class T> T from_string(const std::string& s){
	T t;
	std::istringstream iss(s);
	iss >> t;
	return t;
}

template <class T>
std::string to_string(T t)
{
  std::ostringstream oss;
  oss.precision(15);
  oss << t;
  return oss.str();
}


template<class T>
void allocate_memory(T**& container,const int &m, const int &n){
  container = new T*[m];
  for(int i=0;i<m;i++){
    container[i] = new T[n];
    for (int j=0;j< n;j++)
      container[i][j] = (T)1.0;
  }
}

template<class T>
void dellocate_memory(T**& container,const int &m, const int &n){
  for(int i=0;i<m;i++){
    delete[] container[i];
  }
  delete[] container;
}

template<typename T>
inline bool isinf(T value)
{
  return std::numeric_limits<T>::has_infinity() && value == std::numeric_limits<T>::infinity();
}

double l1_distance(double*& a, double*& b, int& K);

double l2_distance(double*& a, double*& b, int& K);

double gaussian_random_variable(double mean, double variance);

double sigmoid_function(double x);

#endif
